#include <bits/stdc++.h>
using namespace std;
#define int long long
double f,ff,plm;
int n,m,L,V,ans,cnt,t,fz;
int a[2000006],v[2000006],d[2000006],p[2000006],ljd[2000006];
bool ppl[2000006];
int pl[2000006],hy[2000006];
int mls;
struct node{
    int st,en,sh;
};
node dtt[2000006];
bool cmp(node x,node y){
    if(x.en<y.en)return x.en<y.en;
    else return x.st<y.st;
}
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%lld",&t);
    for(int i=1;i<=t;i++){
        cin>>n>>m>>L>>V;
        for(int j=1;j<=L;j++){
            ppl[j]=false;
        }
        cnt=0;ans=m;mls=0;
        for(int j=1;j<=n;j++){
            cin>>d[j]>>v[j]>>a[j];
        }
        for(int j=1;j<=m;j++){
            cin>>p[j];
            hy[p[j]]=j;
            ppl[p[j]]=true;
        }
        sort(p+1,p+m+1);
        for(int j=1;j<=L;j++){
            if(ppl[j])pl[j]=j;
            else pl[j]=pl[j-1];
            //cout<<pl[j]<<" ";
        }
        for(int j=1;j<=n;j++){
            if(a[j]==0){
                if(v[j]>V&&pl[L]!=pl[d[j]-1]){
                    dtt[++cnt].st=d[j];
                    dtt[cnt].en=L;
                    dtt[cnt].sh=j;
                }
            }
            else {
                if(v[j]>V&&a[j]>0&&pl[L]!=pl[d[j]-1]){
                    dtt[++cnt].st=d[j];
                    dtt[cnt].en=L;
                    dtt[cnt].sh=j;
                }
                else if(v[j]<V&&a[j]<0)plm=true;
                else{
                    f=(V*V-v[j]*v[j]);
                    ff=2.0*a[j];
                    f=f/ff;
                    if(f>0){
                        if(a[j]<0){
                            fz=floor(f-0.0001);
                            //cout<<endl<<fz<<endl;
                            if(pl[fz+d[j]]!=pl[d[j]-1]){
                                dtt[++cnt].st=d[j];
                                dtt[cnt].en=fz+d[j];
                                dtt[cnt].sh=j;
                            }
                        }
                        else{
                            fz=ceil(f+0.0001);
                            //cout<<endl<<fz<<endl;
                            if(pl[fz+d[j]-1]!=pl[L]){
                                dtt[++cnt].st=fz+d[j];
                                dtt[cnt].en=L;
                                dtt[cnt].sh=j;
                            }
                        }
                    }
                }
            }
        }
        /*cout<<dtt[1].st<<" "<<dtt[1].en<<endl;
        cout<<dtt[2].st<<" "<<dtt[2].en<<endl;
        cout<<dtt[3].st<<" "<<dtt[3].en<<endl;*/
        sort(dtt+1,dtt+cnt+1,cmp);
        mls=0;
        for(int j=1;j<=cnt;j++){
            if(mls<dtt[j].st){
                ans--;
                mls=hy[pl[dtt[j].en]];

            }
        }
        cout<<cnt<<" "<<ans<<endl;
    }
    return 0;
}
